/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/14
 * Time: 8:33
 * Description:
 */
public class TestDemo {


    public static int add(int x, int y) {
        return x + y;
    }

    public static int add(int x, int y,int c) {
        return x + y+c;
    }

    public static double add(double x, double y) {
        return x + y;
    }

    public static double add(double x, int y) {
        return x + y;
    }

    public static double add(int x, double y) {
        return x + y;
    }


    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int ret = add(a, b);
        System.out.println("ret = " + ret);

        double d1 = 10.2;
        double d2 = 12.5;
        double ret2 = add(d1,d2);
        System.out.println(ret2);

        System.out.println(add(1,2,3));
    }
    
    
    public static int facSum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum = sum + fac(i);
        }
        return sum;
    }

    public static int fac(int n) {
        //求i的阶乘
        int ret = 1;
        for (int j = 1; j <= n; j++) {
            ret = ret*j;
        }
        return ret;
    }

    public static void swap(int x,int y) {
        int tmp = x;
        x = y;
        y = tmp;
        //System.out.println(x+" "+y);
    }

    public static void main5(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a+" "+b);
        swap(a,b);
        System.out.println(a+" "+b);
        /*int ret = facSum(5);
        System.out.println(ret);

        System.out.println(fac(3));*/
    }

    public static void addSum(int x,int y) {
        int ret = x+y;
        System.out.println(ret);
    }

    public static void addSum2() {
        int x = 40;
        int y = 20;
        int ret = x+y;
        System.out.println(ret);
    }

    public static void addSum3(int x,int y) {
        int ret = x+y;
        System.out.println(ret);
    }

    public static int addSum4(int a,int b) {
        int ret = a+b;
        //System.out.println(ret);
        return ret;
        //System.out.println("执行了addSum4");
    }

    public static void main2(String[] args) {
        int a = 20;
        int b = 40;
        System.out.println("第一次调用之前");
        int ret = addSum4(a,b);
        System.out.println(ret);
        System.out.println("第一次调用之后");


        System.out.println("第2次调用之前");
        int ret2 = addSum4(1,2);
        System.out.println(ret2);
        System.out.println("第2次调用之后");


        //System.out.println(addSum4(1,2));


        //方法的调用
        //addSum(a,b);
        //addSum2();
/*        int sum = addSum4(a,b)+10;
        System.out.println(sum);*/

    }


    public static void main1(String[] args) {
        int a = 10;
        int b = 20;
        int ret = a+b;
        System.out.println(ret);
    }
}
